package aula11;

import javax.swing.*;

public class MyFrame{

	private static JFrame frame;
	private JPanel panel;
	private int x = 0;
	private int y = 10;
	
	public JFrame getFrame(){
		return MyFrame.frame;
	}
	
	public void criarTela(){
		frame = new JFrame();
		frame.setSize(400, 300);
		frame.setLocation(600, 600);
		frame.setTitle("Sistema de alunos");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		panel = new JPanel();
		panel.setLayout(null);
	}
	
	public JButton adicionaBotao(String b){
		
		JButton button = new JButton(b);
		int width = 80;
		int height = 20;		
		
		x += 10;
		
		button.setBounds(x, y, 80, 20);
		
		x = x + width;
			
		panel.add(button);
		
		return button;
		
	}
	
	public void adicionaLabel(String l){
		
		JLabel label = new JLabel(l);
		int width = 60;
		int height = 20;		
		
		label.setBounds(10, y, width, height);
		
		panel.add(label);
		
	}
	
	public JLabel adicionaLabel(String l, int ypos){
		
		JLabel label = new JLabel(l);
		int width = 60;
		int height = 20;		
		
		label.setBounds(10, y + ypos, width, height);
		
		panel.add(label);
		
		return label;
		
	}
	
	public JTextField adicionaText(String t){
		
		JTextField text = new JTextField(t);
		int width = 150;
		int height = 20;		
		
		text.setBounds(80, y, width, height);
		
		panel.add(text);
		
		y += 30;
		
		return text;
		
	}
	
	public void setVisilibity(boolean b) {

		frame.add(panel);
		frame.setVisible(b);
	}
	
}
